package com.ym.jiujiangeyou.werther;

import java.io.IOException;


import android.util.Log;
import com.ym.jiujiangeyou.util.Constants;
import com.ym.jiujiangeyou.util.HttpUtil;

/**
 * @author 叶铭
 * @email yeming_1001@163.com
 * @version V1.0 天气信息读取
 */
public class WeatherReader {

	public WeatherReader() {
	}

	/**
	 * @param code 地区编号
	 * @return
	 * @throws IOException
	 * @retur String
	 * @Description: 获取即时天气信息
	 */
	public static String getSimpleWeather(String code){
		String result = get(code, Constants.URL_SIMPLE_WEATHER);
		return result;
	}
	 /** 
	* @param code 地区编号
	* @return
	* @throws IOException  
	* @retur  String 
	* @Description: 获取未来几天天气信息
	*/
	public static String getSixWeather(String code){
	        String result = get(code,Constants.URL_SIX_WEATHER);
	        return result;
	    }
	/** 
	* @param code
	* @param url
	* @return
	* @throws IOException  
	* @retur  String 
	* @Description: 获取天气信息数据
	*/
	public static String get(String code, String url){
		url = url.replaceAll("(.*?)\\$\\{code\\}(.*)", "$1" + code + "$2");
		String json = HttpUtil.httpGet(url) ;
		Log.e("----------------", json);
		return json;
	}
}
